package com.rlax.ccdemo.service.user.codegen;

import com.rlax.corebin.codegen.config.CodeGeneratorConfig;
import com.rlax.corebin.codegen.config.DBGeneratorConfig;
import com.rlax.corebin.codegen.config.TableFillConfig;
import com.rlax.corebin.codegen.generator.CorebinCodeGenerator;

/**
 * 代码生成
 * @author Rlax
 *
 */
public class CodeGenerator {

    public static void main(String[] args) {
        CodeGeneratorConfig codeGeneratorConfig = new CodeGeneratorConfig();

        DBGeneratorConfig dbGeneratorConfig = new DBGeneratorConfig();
        dbGeneratorConfig.setJdbcUrl("jdbc:mysql://127.0.0.1:3306/corebin-demo?autoReconnect=true&useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=UTC");
        dbGeneratorConfig.setJdbcUserName("root");
        dbGeneratorConfig.setJdbcPassword("root");
        dbGeneratorConfig.setJdbcDriver("com.mysql.cj.jdbc.Driver");
        codeGeneratorConfig.setDbGeneratorConfig(dbGeneratorConfig);

        TableFillConfig tableFillConfig = new TableFillConfig();
        tableFillConfig.setCreateTime("create_time");
        tableFillConfig.setCreateBy("create_by");
        tableFillConfig.setUpdateTime("update_time");
        tableFillConfig.setUpdateBy("update_by");
        codeGeneratorConfig.setTableFillConfig(tableFillConfig);

        codeGeneratorConfig.setAuthor("Rlax");
        codeGeneratorConfig.setCodeName("user");
        codeGeneratorConfig.setServiceName("user");
        codeGeneratorConfig.setParentPackage("com.rlax.ccdemo.service.user");
        codeGeneratorConfig.setOutputDirectory("cloud-service\\user-service\\src\\main\\java");
        codeGeneratorConfig.setIncludeTables(new String[]{"upms_user"});
        codeGeneratorConfig.setHasWrapper(false);
        codeGeneratorConfig.setIsSwagger2(true);
        codeGeneratorConfig.setHasPermission(false);
        codeGeneratorConfig.setHasTenantColumn(true);
        codeGeneratorConfig.setTenantColumn("tenant_code");

        new CorebinCodeGenerator(codeGeneratorConfig).run();
    }
}
